/**
 * @param {*} params
 * 对引用对象进行拷贝处理，不进行直接引用
 * example:
 * a={x:3} b=deepClone(a) a.x =4 b.x=3
 */
export function deepClone(params) {
  if (typeof params === "object" && params !== null) {
    if (params instanceof Array) {
      let array = [];
      for (let i of params) {
        array.push(deepClone(i));
      }
      return array;
    } else if (params instanceof RegExp) {
      return new RegExp(params);
    } else {
      let obj = {};
      for (const key in params) {
        if (params.hasOwnProperty(key)) {
          obj[key] = deepClone(params[key]);
        }
      }
      return obj;
    }
  } else {
    return params;
  }
}


/**
 * 获取当前年月日时分秒
 */
export function gettime(){
  var date = new Date();
var Months = date.getMonth() + 1<10? '0'+(date.getMonth() + 1):date.getMonth() + 1;  //月份从0开始，因此要+1
var Dates = date.getDate()<10? '0' + date.getDate():date.getDate()
var Hours = date.getHours()<10? '0' + date.getHours():date.getHours()
var Minutes = date.getMinutes()<10? '0' + date.getMinutes():date.getMinutes()
var Seconds = date.getSeconds()<10? '0' + date.getSeconds():date.getSeconds()
var now = date.getFullYear() + '-' + Months + '-' + Dates + ' ' + Hours + ':' + Minutes + ':' + Seconds;
return now
}

